package com.lijian.dubbo.consumer.main;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.lijian.dubbo.consumer.action.UserAction;

/**
 * 试验zookepper断开后还能继续使用服务
 * @author lijian
 *
 */
public class CacheMainClass {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				"applicationContext.xml");
		context.start();
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		UserAction userAction = context.getBean(UserAction.class);
		String a = userAction.say("user ");
		System.out.println(a);
		
		System.out.println("=============可以开始断开了，这时候把zookeeper停止==============");
		
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		UserAction userAction2 = context.getBean(UserAction.class);
		String a2 = userAction2.say("user ");
		System.out.println(a2);

		// try {
		// System.in.read();
		// } catch (IOException e) {
		// e.printStackTrace();
		// } // 按任意键退出
	}
}
